part of '../fhare.dart';

extension StringText on String {
  SelectableText textSelectable({TextAlign? align, TextStyle? style, int? maxLines, VoidCallback? onTap}) {
    return SelectableText(this, textAlign: align, style: style, maxLines: maxLines, onTap: onTap);
  }

  HareText hareText({TextAlign? align, TextStyle? style}) {
    return HareText(this, style: style, textAlign: align);
  }

  Text text(
      {Key? key, TextAlign? align, TextStyle? style, bool? mono, double? fontSize, Color? color, FontWeight? weight, int? maxLines, bool? softWrap, TextOverflow? overflow = TextOverflow
          .clip, Locale? locale}) {
    TextStyle? st;
    if (style == null && (fontSize != null || color != null || weight != null || mono == true))
      st = TextStyle(fontFeatures: mono == true ? [FontFeature.tabularFigures()] : null, fontSize: fontSize, color: color, fontWeight: weight);
    return Text(this, key: key,
        style: style ?? st,
        textAlign: align,
        overflow: overflow,
        softWrap: softWrap,
        maxLines: maxLines,
        locale: locale);
  }

  Text bodyLarge(
      {Key? key, BuildContext? context, TextAlign? align, double? fontSize, Color? color, FontWeight? fontWeight, int? maxLines, bool? softWrap, TextOverflow? overflow = TextOverflow
          .clip, Locale? locale}) {
    BuildContext c = context ?? HareApp.currentContext;
    TextStyle style = c.themeData.textTheme.bodyLarge!.copyWith(color: color, fontSize: fontSize, fontWeight: fontWeight);
    return Text(this, key: key,
        style: style,
        textAlign: align,
        overflow: overflow,
        softWrap: softWrap,
        maxLines: maxLines,
        locale: locale);
  }

  Text bodyMedium(
      {Key? key, BuildContext? context, TextAlign? align, double? fontSize, Color? color, FontWeight? fontWeight, int? maxLines, bool? softWrap, TextOverflow? overflow = TextOverflow
          .clip, Locale? locale}) {
    BuildContext c = context ?? HareApp.currentContext;
    TextStyle style = c.themeData.textTheme.bodyMedium!.copyWith(color: color, fontSize: fontSize, fontWeight: fontWeight);
    return Text(this, key: key,
        style: style,
        textAlign: align,
        overflow: overflow,
        softWrap: softWrap,
        maxLines: maxLines,
        locale: locale);
  }

  Text bodySmall(
      {Key? key, BuildContext? context, TextAlign? align, double? fontSize, Color? color, FontWeight? fontWeight, int? maxLines, bool? softWrap, TextOverflow? overflow = TextOverflow
          .clip, Locale? locale}) {
    BuildContext c = context ?? HareApp.currentContext;
    TextStyle style = c.themeData.textTheme.bodySmall!.copyWith(color: color, fontSize: fontSize, fontWeight: fontWeight);
    return Text(this, key: key,
        style: style,
        textAlign: align,
        overflow: overflow,
        softWrap: softWrap,
        maxLines: maxLines,
        locale: locale);
  }

  Text titleSmall(
      {Key? key, BuildContext? context, TextAlign? align, double? fontSize, Color? color, FontWeight? fontWeight, int? maxLines, bool? softWrap, TextOverflow? overflow = TextOverflow
          .clip, Locale? locale}) {
    BuildContext c = context ?? HareApp.currentContext;
    TextStyle style = c.themeData.textTheme.titleSmall!.copyWith(color: color, fontSize: fontSize, fontWeight: fontWeight);
    return Text(this, key: key,
        style: style,
        textAlign: align,
        overflow: overflow,
        softWrap: softWrap,
        maxLines: maxLines,
        locale: locale);
  }

  Text titleMedium(
      {Key? key, BuildContext? context, TextAlign? align, double? fontSize, Color? color, FontWeight? fontWeight, int? maxLines, bool? softWrap, TextOverflow? overflow = TextOverflow
          .clip, Locale? locale}) {
    BuildContext c = context ?? HareApp.currentContext;
    TextStyle style = c.themeData.textTheme.titleMedium!.copyWith(color: color, fontSize: fontSize, fontWeight: fontWeight);
    return Text(this, key: key,
        style: style,
        textAlign: align,
        overflow: overflow,
        softWrap: softWrap,
        maxLines: maxLines,
        locale: locale);
  }

  Text titleLarge(
      {Key? key, BuildContext? context, TextAlign? align, double? fontSize, Color? color, FontWeight? fontWeight, int? maxLines, bool? softWrap, TextOverflow? overflow = TextOverflow
          .clip, Locale? locale}) {
    BuildContext c = context ?? HareApp.currentContext;
    TextStyle style = c.themeData.textTheme.titleLarge!.copyWith(color: color, fontSize: fontSize, fontWeight: fontWeight);
    return Text(this, key: key,
        style: style,
        textAlign: align,
        overflow: overflow,
        softWrap: softWrap,
        maxLines: maxLines,
        locale: locale);
  }
}
